package grun

import (
	"encoding/json"
	"fmt"
	log "github.com/sirupsen/logrus"
	"strings"
)

type PrintParamCfg struct {
	IsQuiet bool
}

func PrintParam(ParamMap map[string]string, PrintParamCfg PrintParamCfg) {
	if PrintParamCfg.IsQuiet {
		return
	}
	log.Println("* 指定参数：")
	for key, value := range ParamMap {
		log.Println(fmt.Sprintf("* %v：%v", key, value))
	}
}

func PrintStruct(ParamList ...interface{}) {
	for i, Param := range ParamList {
		fmt.Println(i, strings.Repeat("*", 50))
		if pb, err := json.Marshal(&Param); err != nil {
			log.Errorln(fmt.Sprintf("解析第%v个参数出错", i))
		} else {
			fmt.Println(string(pb))
		}
	}
	fmt.Println(strings.Repeat("*", 50))
}
